function t(t) {
    var a = {
        action: "code",
        contr: "treasure",
        token: wx.getStorageSync("token"),
        id: t.data.id,
        p: t.data.p
    };
    e.default.request(a, function(a) {
        var e = a.info.treasure_code;
        t.data.p > 1 && (e = t.data.data.concat(e)), t.setData({
            data: e
        }), a.info.length < 10 ? t.setData({
            isover: !1
        }) : t.data.p++;
    });
}

var a, e = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../../utils/tools.js"));

getApp();

Page({
    data: {
        close_code: !1,
        currentNun: 1,
        isRequest: 1,
        pwd: "",
        p: 1
    },
    handleClose: function() {
        this.setData({
            purchase_show: !1,
            isClosing: !0
        });
    },
    onLoad: function(t) {
        (a = this).data.id = t.id;
    },
    onReady: function() {},
    onShow: function() {
        var n = {
            action: "detail",
            contr: "treasure",
            token: wx.getStorageSync("token"),
            id: a.data.id
        };
        e.default.request(n, function(t) {
            a.setData(t.info);
        }), t(this);
    },
    handleSeeMoreRecord: function() {
        t(this);
    },
    catchtouchmove: function() {},
    handleLessOne: function() {
        var t = this.data.currentNun + 1;
        this.setData({
            currentNun: t
        });
    },
    bindInputNum: function(t) {
        this.setData({
            currentNun: t.detail.value
        });
    },
    handleAddOne: function() {
        if (this.data.currentNun < 2) return !0;
        var t = this.data.currentNun - 1;
        this.setData({
            currentNun: t
        });
    },
    hindleLookNumber: function() {
        var t = {
            action: "myCode",
            contr: "treasure",
            token: wx.getStorageSync("token"),
            id: a.data.id
        };
        e.default.request(t, function(t) {
            a.setData(t.info), a.setData({
                close_code: !0
            });
        });
    },
    close: function() {
        this.setData({
            close_code: !1
        });
    },
    hanleExchangeClick: function() {
        this.data.address ? this.setData({
            purchase_show: !0
        }) : wx.navigateTo({
            url: "/bh_farm/pages/address/address"
        });
    },
    onHide: function() {},
    onUnload: function() {},
    hide_luck_pwd: function() {
        this.setData({
            luck_pwd_show: !1,
            pwd: ""
        });
    },
    inputLuckPwd: function(t) {
        this.setData({
            pwd: t.detail.value
        });
    },
    handleBuy: function() {
        if (1 != this.data.isRequest) return !0;
        if (2 == this.data.treasure.type) {
            if (!this.data.pwd && a.data.luck_pwd_show) return void wx.showToast({
                icon: "none",
                title: "请填写夺宝口令"
            });
            if (!this.data.pwd && !a.data.luck_pwd_show) return void a.setData({
                luck_pwd_show: !0
            });
        }
        this.data.isRequest = 2;
        var t = {
            action: "buy",
            contr: "treasure",
            token: wx.getStorageSync("token"),
            id: a.data.id,
            currentNun: a.data.currentNun,
            pwd: a.data.pwd
        };
        e.default.request(t, function(t) {
            a.data.isRequest = 1, a.setData({
                pwd: ""
            }), 2 == t.status ? wx.showModal({
                title: "提示",
                mask: !0,
                content: t.info,
                showCancel: !1
            }) : (a.setData({
                luck_pwd_show: !1
            }), wx.navigateTo({
                url: "../success/success?id=" + t.info.id
            }));
        });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_farm/pages/index/index?parent_id=" + this.data.share.member_id
        };
    }
});